import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;


public class SocketTester {

    public static void main(String[] args) throws IOException {
	System.out.println("Reciever waiting... \n");
	
	InetAddress receiverAddress = InetAddress.getLocalHost();
	
	byte[] bufferR = new byte[10];
	
	DatagramSocket socketR = new DatagramSocket(5000);
	
	DatagramPacket packetR = new DatagramPacket(bufferR, bufferR.length, receiverAddress, 5000);
	
	socketR.receive(packetR);	
	
	byte[] bufferFinal = packetR.getData();
	
	for (int i = 0; i < bufferFinal.length; i++) {
	    System.out.print(bufferFinal[i] + " ");
	}

	System.out.println("\n");
	System.out.println("Packet received.");
    }

}

